//
//  ViewController.swift
//  Emotion
//
//  Created by lirenqiang on 16/6/1.
//  Copyright © 2016年 lirenqiang. All rights reserved.
//

import UIKit

let EmoticonBtnDidClickNotification = "EmoticonBtnDidClickNotification"

class ViewController: UIViewController {

    @IBOutlet weak var textView: SLTextView!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        textView.becomeFirstResponder()
        
        textView.inputView = keyboardView
        NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(ViewController.inserEmoticon(_:)), name: EmoticonBtnDidClickNotification, object: nil)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
        
    }

    
    //MARK: - 懒加载inputView
    private lazy var keyboardView:SLEmoticonKeyboardView = SLEmoticonKeyboardView()
    
    
    @IBAction func show(sender: AnyObject) {
        
        print(textView.fullText())
    }
    
    
    //MARK: - 通知的方法
    @objc private func inserEmoticon(n: NSNotification) {
        
        guard let em = n.object as? SLEmoticon else {
            return 
        }
        
        textView.inserEmoticon(em)

    }
}



































